from jsonpath_ng import parse

data = {
    "inc": {
        "a": {"b": {
            "c": {
                "key": "value",
                'b': {"key1": "value1"}
            },
        }},
        "d": {"c": 456}
    }
}

# 从跟节点开始找任意层级的c的值
expr = parse('$..c')  # 递归查找所有 c
matches = [m.value for m in expr.find(data)]  # 遍历取值
print(matches)  # [{'key': 'value', 'b': {'key1': 'value1'}}, 456]
